import BTTree from '../../Base/BTTree'
import CompositeSelector from '../Composite/CompositeSelector'
import ConditionalMP from '../Conditional/ConditionalMP'
import DecoratorRepeater from '../Decorator/DecoratorRepeater'

export default class MyTree extends BTTree {
  constructor() {
    super()
    this.init()
  }
  init() {
    // 测试行为树，参照图片resources/texture/行为树案例1.png
    // this.root = new CompositeSequence([
    //   new CompositeSelector([
    //     new CompositeSequence([new ConditionalMP(), new CompositeSequence([new ActionWait(), new ActionSkill()])]),
    //     new CompositeSequence([new ConditionalHP(), new ActionAttack()]),
    //     new CompositeRandomSequence([new ActionWork(), new ActionSleep()])
    //   ])
    // ])

    // 测试DecoratorInverter行为树，参照图片resources/texture/装饰反转节点行为树.png
    // this.root = new CompositeSequence([
    //   new DecoratorInverter([new DecoratorInverter([new ActionLog('haha')])]),
    //   new ActionLog('heihei')
    // ])

    // 测试AbortType行为树，参照图片resources/texture/AbortType行为树案例.png
    // this.root = new CompositeSequence([
    //   new CompositeSelector([
    //     new CompositeSequence(
    //       [new ConditionalMP(), new CompositeSequence([new ActionWait(), new ActionSkill()])],
    //       AbortType.Self
    //     ),
    //     new CompositeSequence([new ConditionalHP(), new ActionAttack()]),
    //     new CompositeRandomSequence([new ActionWork(), new ActionSleep()])
    //   ])
    // ])

    // 测试CompositeParallel并行行为树，参照图片resources/texture/CompositeParallel并行行为树.png
    // this.root = new CompositeSelector([new CompositeParallel([new ActionWait(), new ActionWork(), new ActionSleep()])])

    // 测试每个条件中断只能打断并行节点下自己那部分节点行为树，参照图片resources/texture/每个条件中断只能打断并行节点下自己那部分节点行为树.png
    // this.root = new CompositeSelector([
    //   new CompositeParallel([
    //     new CompositeSelector([new ConditionalHP(), new ActionWork(4000)], AbortType.Self),
    //     new CompositeSelector([new ConditionalMP(), new ActionSleep(8000)], AbortType.Self)
    //   ])
    // ])

    // 测试DecoratorRepeater行为树，参照图片resources/texture/测试repeater装饰器行为树.png
    this.root = new CompositeSelector([new DecoratorRepeater([new ConditionalMP()])])
  }
}
